package com.briup.recognition.service.impl;

import com.briup.recognition.bean.BaseLog;
import com.briup.recognition.bean.BaseLogExample;
import com.briup.recognition.dao.BaseLogMapper;
import com.briup.recognition.service.BaseLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @Author: xiaoxiao
 * @Description:
 * @DateTime: 2021/3/28$ 19:53$
 * @Params: $
 * @Return $
 */
@Service
public class BaseLogServiceImpl implements BaseLogService {

    @Resource
    private BaseLogMapper baseLogMapper;

    @Override
    public List<BaseLog> query(){
        BaseLogExample example = new BaseLogExample();
        return baseLogMapper.selectByExample(example);
    }

    @Override
    public void saveOrUpdate(BaseLog baseLog){
        if (baseLog.getId()!=null){
            baseLogMapper.updateByPrimaryKey(baseLog);
        } else {
            baseLog.setLogTime(new Date().getTime());
            baseLogMapper.insert(baseLog);
        }
    }

    @Override
    public void deleteById(long id){
        baseLogMapper.deleteByPrimaryKey(id);
    }
}
